package com.larry.tinyweb.plugin;

import com.larry.tinyweb.core.RequestEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by larry on 16/9/23.
 * 插件管理器
 *
 */
public class PluginManager {
    private static List<Plugin> plugins = new ArrayList<>();

    public static void add(Plugin plugin) {
        plugins.add(plugin);
    }

    public static void doPlugin(RequestEntity requestEntity) throws Exception {
        for (Plugin plugin : plugins) {
            if (requestEntity.canPlugin()) plugin.plugin(requestEntity);
        }
    }
}
